package com.dobbyspringside.examples.quickstart.repository;

import com.dobbyspringside.examples.quickstart.entity.Task;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.awt.print.Pageable;

/**
 * Created by liguoqing on 2016/2/16.
 */
public interface TaskDao extends PagingAndSortingRepository<Task,Long>, JpaSpecificationExecutor<Task> {

    Page<Task> findByUserId(Long id,Pageable pageRequest);

    @Modifying
    @Query("delete from Task task where task.user.id=?1")
    void deleteByUserId(Long id);
}
